<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Cubic Spline Interpolation</title>
<title>CMSIS-DSP: Cubic Spline Interpolation</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="printComponentTabs.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 46px;">
  <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMSIS-DSP
   &#160;<span id="projectnumber">Version 1.8.0</span>
   </div>
   <div id="projectbrief">CMSIS DSP Software Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
    <ul class="tablist">
      <script type="text/javascript">
		<!--
		writeComponentTabs.call(this);
		//-->
      </script>
	  </ul>
</div>
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__SplineInterpolate.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Cubic Spline Interpolation<div class="ingroups"><a class="el" href="group__groupSupport.html">Support Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Spline interpolation is a method of interpolation where the interpolant is a piecewise-defined polynomial called "spline".  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga4ef053a783b251b085454b28f8aecb94"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__SplineInterpolate.html#ga4ef053a783b251b085454b28f8aecb94">arm_spline_f32</a> (<a class="el" href="structarm__spline__instance__f32.html">arm_spline_instance_f32</a> *<a class="el" href="arm__bayes__example__f32_8c.html#ad5af783c9e1eb1514dec0a59dac35eb7">S</a>, const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *xq, <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *pDst, uint32_t <a class="el" href="arm__variance__example__f32_8c.html#ab6558f40a619c2502fbc24c880fd4fb0">blockSize</a>)</td></tr>
<tr class="memdesc:ga4ef053a783b251b085454b28f8aecb94"><td class="mdescLeft">&#160;</td><td class="mdescRight">Processing function for the floating-point cubic spline interpolation.  <a href="group__SplineInterpolate.html#ga4ef053a783b251b085454b28f8aecb94">More...</a><br /></td></tr>
<tr class="separator:ga4ef053a783b251b085454b28f8aecb94"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5370a3c4a213e15bf57726406ec52ae0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__SplineInterpolate.html#ga5370a3c4a213e15bf57726406ec52ae0">arm_spline_init_f32</a> (<a class="el" href="structarm__spline__instance__f32.html">arm_spline_instance_f32</a> *<a class="el" href="arm__bayes__example__f32_8c.html#ad5af783c9e1eb1514dec0a59dac35eb7">S</a>, <a class="el" href="arm__math_8h.html#a545cad4aaf64955a2d2e93d7e806bcd7">arm_spline_type</a> type, const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *x, const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *y, uint32_t n, <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *coeffs, <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *tempBuffer)</td></tr>
<tr class="memdesc:ga5370a3c4a213e15bf57726406ec52ae0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization function for the floating-point cubic spline interpolation.  <a href="group__SplineInterpolate.html#ga5370a3c4a213e15bf57726406ec52ae0">More...</a><br /></td></tr>
<tr class="separator:ga5370a3c4a213e15bf57726406ec52ae0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<dl class="section user"><dt>Introduction</dt><dd></dd></dl>
<p>Given a function f defined on the interval [a,b], a set of n nodes x(i) where a=x(1)&lt;x(2)&lt;...&lt;x(n)=b and a set of n values y(i) = f(x(i)), a cubic spline interpolant S(x) is defined as:</p>
<pre>
         S1(x)       x(1) &lt; x &lt; x(2)
 S(x) =   ...         
         Sn-1(x)   x(n-1) &lt; x &lt; x(n)
 </pre><p>where</p>
<pre> 
 Si(x) = a_i+b_i(x-xi)+c_i(x-xi)^2+d_i(x-xi)^3    i=1, ..., n-1
 </pre><dl class="section user"><dt>Algorithm</dt><dd></dd></dl>
<p>Having defined h(i) = x(i+1) - x(i)</p>
<pre>
 h(i-1)c(i-1)+2[h(i-1)+h(i)]c(i)+h(i)c(i+1) = 3/h(i)*[a(i+1)-a(i)]-3/h(i-1)*[a(i)-a(i-1)]    i=2, ..., n-1
 </pre><p>It is possible to write the previous conditions in matrix form (Ax=B). In order to solve the system two boundary conidtions are needed.</p><ul>
<li>Natural spline: S1''(x1)=2*c(1)=0 ; Sn''(xn)=2*c(n)=0 In matrix form:</li>
</ul>
<pre>
 |  1        0         0  ...    0         0           0     ||  c(1)  | |                        0                        |
 | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
 | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
 |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
 |  0        0         0  ...    0         0           1     ||  c(n)  | |                        0                        |
 </pre><ul>
<li>Parabolic runout spline: S1''(x1)=2*c(1)=S2''(x2)=2*c(2) ; Sn-1''(xn-1)=2*c(n-1)=Sn''(xn)=2*c(n) In matrix form:</li>
</ul>
<pre>
 |  1       -1         0  ...    0         0           0     ||  c(1)  | |                        0                        |
 | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
 | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
 |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
 |  0        0         0  ...    0        -1           1     ||  c(n)  | |                        0                        |
 </pre><p>A is a tridiagonal matrix (a band matrix of bandwidth 3) of size N=n+1. The factorization algorithms (A=LU) can be simplified considerably because a large number of zeros appear in regular patterns. The Crout method has been used: 1) Solve LZ=B</p>
<pre>
 u(1,2) = A(1,2)/A(1,1)
 z(1)   = B(1)/l(11)</pre><pre> FOR i=2, ..., N-1
   l(i,i)   = A(i,i)-A(i,i-1)u(i-1,i)
   u(i,i+1) = a(i,i+1)/l(i,i)
   z(i)     = [B(i)-A(i,i-1)z(i-1)]/l(i,i)</pre><pre> l(N,N) = A(N,N)-A(N,N-1)u(N-1,N)
 z(N)   = [B(N)-A(N,N-1)z(N-1)]/l(N,N)
 </pre><p>2) Solve UX=Z</p>
<pre>
 c(N)=z(N)</pre><pre> FOR i=N-1, ..., 1
   c(i)=z(i)-u(i,i+1)c(i+1) 
 </pre><p>c(i) for i=1, ..., n-1 are needed to compute the n-1 polynomials. b(i) and d(i) are computed as:</p><ul>
<li>b(i) = [y(i+1)-y(i)]/h(i)-h(i)*[c(i+1)+2*c(i)]/3</li>
<li>d(i) = [c(i+1)-c(i)]/[3*h(i)] Moreover, a(i)=y(i).</li>
</ul>
<dl class="section user"><dt>Behaviour outside the given intervals</dt><dd></dd></dl>
<p>It is possible to compute the interpolated vector for x values outside the input range (xq&lt;x(1); xq&gt;x(n)). The coefficients used to compute the y values for xq&lt;x(1) are going to be the ones used for the first interval, while for xq&gt;x(n) the coefficients used for the last interval.</p>
<dl class="section user"><dt>Initialization function</dt><dd></dd></dl>
<p>The initialization function takes as input two arrays that the user has to allocate: <code>coeffs</code> will contain the b, c, and d coefficients for the (n-1) intervals (n is the number of known points), hence its size must be 3*(n-1); <code>tempBuffer</code> is temporally used for internal computations and its size is n+n-1.</p>
<dl class="section user"><dt></dt><dd></dd></dl>
<p>The x input array must be strictly sorted in ascending order and it must not contain twice the same value (x(i)&lt;x(i+1)). </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga4ef053a783b251b085454b28f8aecb94"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4ef053a783b251b085454b28f8aecb94">&#9670;&nbsp;</a></span>arm_spline_f32()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_spline_f32 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structarm__spline__instance__f32.html">arm_spline_instance_f32</a> *&#160;</td>
          <td class="paramname"><em>S</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>xq</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>pDst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>blockSize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">S</td><td>points to an instance of the floating-point spline structure. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">xq</td><td>points to the x values ot the interpolated data points. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pDst</td><td>points to the block of output data. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">blockSize</td><td>number of samples of output data. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga5370a3c4a213e15bf57726406ec52ae0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5370a3c4a213e15bf57726406ec52ae0">&#9670;&nbsp;</a></span>arm_spline_init_f32()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void arm_spline_init_f32 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structarm__spline__instance__f32.html">arm_spline_instance_f32</a> *&#160;</td>
          <td class="paramname"><em>S</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="arm__math_8h.html#a545cad4aaf64955a2d2e93d7e806bcd7">arm_spline_type</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>n</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> *&#160;</td>
          <td class="paramname"><em>tempBuffer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">S</td><td>points to an instance of the floating-point spline structure. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">type</td><td>type of cubic spline interpolation (boundary conditions) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">x</td><td>points to the x values of the known data points. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">y</td><td>points to the y values of the known data points. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">n</td><td>number of known data points. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>coefficients array for b, c, and d </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">tempBuffer</td><td>buffer array for internal computations </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Mar 17 2020 15:01:25 for CMSIS-DSP Version 1.8.0 by Arm Ltd. All rights reserved.
	<!--
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 
	-->
	</li>
  </ul>
</div>
</body>
</html>
